package base.string;

/**
 * @Description: 作用描述
 * @Author: hmm
 * @CreateDate: 2019/8/2$ 21:37$
 * @UpdateUser: hmm
 * @UpdateDate: 2019/8/2$ 21:37$
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class StringUse {
    public static void main(String[] args) {
        String s = "123456789";
        System.out.println(s.substring(0,4));
        String a = "abc";
        String b = "abc";
        changeString(a);
        System.out.println(a);
        String c = new String("abc");
        String d = new String("abc");
        changeString(c);
        System.out.println(c);
        String s1 = a.intern();
        String s2 = b.intern();
        String s3 = c.intern();
        String s4 = d.intern();

        System.out.println("a==b" +"比较"+ (a == b));
        System.out.println("a equals b" +"比较"+ (a.equals(b)));
        System.out.println("a==c" +"比较"+ (a == c));
        System.out.println("a equals c" +"比较"+ (a.equals(c)));
        System.out.println("c==d" +"比较"+ (c == d));
        System.out.println("c equals d" +"比较"+ (c.equals(d)));

        System.out.println(s1==s2);
        System.out.println(s1==s3);
        System.out.println(s3==s4);

        System.out.println(a.hashCode());
    }

    private static void changeString(String s) {
        s = new String("test");
    }
}
